// 函数是一等公民
// cargo test -- --nocapture test_fn_is_first_class_citizen

fn apply(value: i32, f: fn(i32) -> i32) -> i32 {
    f(value)
}

fn square(value: i32) -> i32 {
    value * value
}

fn cube(value: i32) -> i32 {
    value * value * value
}

#[test]
fn test_fn_is_first_class_citizen() {
    println!("apply square: {}", apply(2, square));
    println!("apply cube: {}", apply(2, cube));
}
